home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Src / MTAconsole / workops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  20.1 KB  |  1,027 lines

  1. /* workops.c: routines that do work */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Src/MTAconsole/RCS/workops.c,v 6.0 1991/12/18 20:26:48 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Src/MTAconsole/RCS/workops.c,v 6.0 1991/12/18 20:26:48 jpo Rel $
  9.  *
  10.  * $Log: workops.c,v $
  11.  * Revision 6.0  1991/12/18  20:26:48  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include    "console.h"
  19.  
  20. extern CMD_TABLE    chantbl_commands[],
  21.             mtatbl_commands[],
  22.             msgtbl_commands[];
  23. extern char        *strdup(), *itoa(),
  24.             *stripstr(),
  25.             *rcmd_srch();
  26. extern void        ChanToggle(), MtaToggle(), MsgToggle(), ChangeMode();
  27. extern struct recip    *find_recip();
  28.  
  29. /* ARGUSED */
  30. ChanForce(chan)
  31. struct chan_struct    *chan;
  32. {
  33.     char    *args[3];
  34.  
  35.     args[0] = chan->channelname;
  36.     args[2] = NULLCP;
  37.     if (chan->status->enabled != TRUE) {
  38.         args[1] = rcmd_srch((int) chanstart, chantbl_commands);
  39.         my_invoke(chanstart, args);
  40.     }
  41.     if (chan->status->cachedUntil != 0) {
  42.         args[1] = rcmd_srch((int) chanclear, chantbl_commands);
  43.         my_invoke(chanclear, args);
  44.     }
  45. }
  46.  
  47. extern struct chan_struct    *currentchan, **globallist;
  48. extern int            num_channels;
  49. extern struct mta_struct    *currentmta;
  50. extern struct msg_struct    *currentmsg;
  51.  
  52. ChanNext()
  53. {
  54.     if (currentchan == NULL)
  55.         currentchan = globallist[0];
  56.     else {
  57.         int i = 0;
  58.         while (i < num_channels
  59.                && currentchan != globallist[i]) i++;
  60.         if (i < num_channels-1)
  61.             currentchan = globallist[i+1];
  62.         else
  63.             currentchan = globallist[0];
  64.     }
  65.     currentmta = NULL;
  66.     currentmsg = NULL;
  67.     refresh_control_channel();
  68. }
  69.  
  70. ChanPrev()
  71. {
  72.     if (currentchan == NULL)
  73.         currentchan = globallist[num_channels - 1];
  74.     else {
  75.         int i = 0;
  76.         while (i < num_channels
  77.                && currentchan != globallist[i]) i++;
  78.         if (i == 0)
  79.             currentchan = globallist[num_channels - 1];
  80.         else
  81.             currentchan = globallist[i - 1];
  82.     }
  83.     currentmta = NULL;
  84.     currentmsg = NULL;
  85.     refresh_control_channel();
  86. }
  87.  
  88. extern Widget    channel_label, mta_label, msg_label;
  89. extern int    read_currentchan, chan_info_shown, mta_info_shown, msg_info_shown;
  90.  
  91. refresh_control_channel()
  92. {    
  93.     reset_label(channel_label);
  94.     reset_label(mta_label);
  95.     reset_label(msg_label);
  96.     if (read_currentchan) {
  97.         add_mta_refresh_list(currentchan->channelname);
  98.         construct_event(mtaread);
  99.     }
  100.     if (chan_info_shown == TRUE)
  101.         chan_display_info(currentchan);
  102. }
  103.  
  104. ChanDownForce (chan)
  105. struct chan_struct    *chan;
  106. {
  107.     add_mta_refresh_list(chan->channelname);
  108.     my_invoke(mtaread, &(chan->channelname));
  109.     ChanForce (chan);
  110. }
  111.  
  112. /* ARGSUSED */
  113. ChanControl(op, channel, mytime)
  114. Operations op;
  115. char    *channel,
  116.     *mytime;
  117. {
  118.     char    *str,
  119.         *chan,
  120.         **args;
  121.     str = strdup(channel);
  122.     chan = stripstr(str);
  123.     args = (char **) calloc(3, sizeof(char *));
  124.     args[0] = chan;
  125.     args[1] = rcmd_srch((int) op, chantbl_commands);
  126.     args[2] = mytime;
  127.     my_invoke(op, args);
  128.     free((char *) args);
  129.     free(str);
  130. }
  131.  
  132. /* ARGSUSED */
  133. MtaForce(mta, chan)
  134. struct mta_struct    *mta;
  135. struct chan_struct    *chan;
  136. {
  137.     char    *args[4];
  138.     args[0] = chan->channelname;
  139.     args[1] = mta->mta;
  140.     args[3] = NULLCP;
  141.     
  142.     if (mta->status->enabled != TRUE) {
  143.         args[2] = rcmd_srch((int) mtastart,mtatbl_commands);
  144.         my_invoke(mtastart, args);
  145.     }
  146.     if (mta->status->cachedUntil != 0) {
  147.         args[2] = rcmd_srch((int) mtaclear,mtatbl_commands);
  148.         my_invoke(mtaclear, args);
  149.     }
  150.     ChanForce(chan);
  151. }
  152.  
  153. extern char    *msginfo_args[];
  154.  
  155. MtaDownForce (chan, mta)
  156. struct chan_struct    *chan;
  157. struct mta_struct    *mta;
  158. {
  159.     msginfo_args[0] = chan->channelname;
  160.     msginfo_args[1] = mta->mta;
  161.     if (is_loc_chan(chan) == TRUE)
  162.         msginfo_args[2] = (char *) 1;
  163.     else
  164.         msginfo_args[2] = (char *) 0;
  165.     my_invoke (readchannelmtamessage, msginfo_args);
  166.     /* reset after message down force */
  167.     msginfo_args[0] = chan->channelname;
  168.     msginfo_args[1] = mta->mta;
  169.     if (is_loc_chan(chan) == TRUE)
  170.         msginfo_args[2] = (char *) 1;
  171.     else
  172.         msginfo_args[2] = (char *) 0;
  173.     if (mta->status->enabled != TRUE) {
  174.         msginfo_args[2] = rcmd_srch((int) mtastart,mtatbl_commands);
  175.         my_invoke(mtastart, msginfo_args);
  176.     }
  177.     if (mta->status->cachedUntil != 0) {
  178.         msginfo_args[2] = rcmd_srch((int) mtaclear,mtatbl_commands);
  179.         my_invoke(mtaclear, msginfo_args);
  180.     }
  181. }    
  182.  
  183. /* ARGSUSED */
  184. MtaControl(op, givenmta, givenchan, time)
  185. Operations    op;
  186. char        *givenmta,
  187.         *givenchan,
  188.         *time;
  189. {
  190.     char    *str1,
  191.         *str2,
  192.         *mta,
  193.         *chan,
  194.         **args;
  195.  
  196.     /* get selection and all that */
  197.     str1 = strdup(givenmta);
  198.     mta = stripstr(str1);
  199.     
  200.     str2 = strdup(givenchan);
  201.     chan = stripstr(str2);
  202.     
  203.     args = (char **) calloc(4, sizeof(char *));
  204.     args[0] = chan;
  205.     args[1] = mta;
  206.     args[2] = rcmd_srch((int) op, mtatbl_commands);
  207.     args[3] = time;
  208.     my_invoke(op,args);
  209.     free((char *) args);
  210.     free(str1);
  211.     free(str2);
  212. }
  213.  
  214. /* ARGSUSED */
  215. MsgForce(msg, usrs, mta, chan)
  216. struct msg_struct    *msg;
  217. char            *usrs;
  218. struct mta_struct    *mta;
  219. struct chan_struct    *chan;
  220. {
  221.     char    *usrlist[20],
  222.         **args;
  223.     int    numberUsrs = 0, force;
  224.     int    i = 0, ix, all;
  225.     struct recip    *temp;
  226.     if (msg == NULL
  227.         || msg->msginfo == NULL) return;
  228.  
  229.     if (strcmp(usrs, "*") == 0) {
  230.         all = TRUE;
  231.         for (temp = msg->reciplist, numberUsrs = 0; 
  232.              temp != NULL; temp = temp -> next, numberUsrs++)
  233.             continue;
  234.     } else {
  235.         all = FALSE;
  236.         numberUsrs = sstr2arg(usrs, 20, usrlist, ",");
  237.     }
  238.     
  239.     args = (char **) calloc((unsigned)(4+numberUsrs), sizeof(char *));
  240.     args[0] = msg->msginfo->queueid;
  241.     args[1] = NULL;
  242.  
  243.     ix = 3;
  244.     force = FALSE;
  245.  
  246.     if (all == TRUE) {
  247.         for (temp = msg->reciplist; temp != NULL; temp = temp -> next)
  248.             if (temp->status
  249.                 && temp->status->enabled != TRUE) {
  250.                 args[ix++] = itoa(temp->id);
  251.                 force = TRUE;
  252.             }
  253.     } else {
  254.         while (i < numberUsrs && ix < (3+numberUsrs)) {
  255.             if ((temp = find_recip(msg, atoi(usrlist[i]))) != NULL
  256.                 && temp->status
  257.                 && temp->status->enabled != TRUE) {
  258.                 args[ix++] = usrlist[i];
  259.                 force = TRUE;
  260.             }
  261.             i++;
  262.         }
  263.     }
  264.     if (force == TRUE) {
  265.         args[ix] = NULLCP;
  266.         args[2] = rcmd_srch((int) msgstart, msgtbl_commands);
  267.         my_invoke(msgstart, args);
  268.     }
  269.  
  270.     ix = 3;
  271.     i = 0;
  272.     force = FALSE;
  273.  
  274.     if (all == TRUE) {
  275.         for (temp = msg->reciplist; temp != NULL; temp = temp -> next)
  276.             if (temp->status
  277.                 && temp->status->cachedUntil != 0) {
  278.                 args[ix++] = itoa(temp->id);
  279.                 force = TRUE;
  280.             }
  281.     } else {
  282.         while (i < numberUsrs && ix < (3+numberUsrs)) {
  283.             if ((temp = find_recip(msg, atoi(usrlist[i]))) != NULL
  284.                 && temp->status
  285.                 && temp->status->cachedUntil != 0) {
  286.                 args[ix++] = usrlist[i];
  287.                 force = TRUE;
  288.             }
  289.             i++;
  290.         }
  291.     }
  292.     if (force == TRUE) {
  293.         args[ix] = NULLCP;
  294.         args[2] = rcmd_srch((int) msgclear, msgtbl_commands);
  295.         my_invoke(msgstart, args);
  296.     }
  297.     free((char *) args);
  298.     MtaForce(mta, chan);
  299. }
  300.  
  301. MsgDownForce (msg)
  302. struct msg_struct    *msg;
  303. {
  304.     struct recip    *ix;
  305.     int        recip_count = 0, i, j, force;
  306.     char        **args;
  307.  
  308.     if (msg == NULL
  309.         || msg->msginfo == NULL) return;
  310.     
  311.     for (ix = msg -> reciplist; ix != NULL; 
  312.          recip_count++, ix = ix -> next)
  313.         continue;
  314.     
  315.     args = (char **) calloc((unsigned)(4+recip_count),
  316.                 sizeof(char *));
  317.     args[0] = msg->msginfo->queueid;
  318.     args[1] = NULL;
  319.     i = 3;
  320.     ix = msg -> reciplist;
  321.     force = FALSE;
  322.     while (ix != NULL) {
  323.         if (ix -> status
  324.             && ix -> status -> enabled != TRUE) {
  325.             args[i++] = itoa(ix->id);
  326.  
  327.             force = TRUE;
  328.         }
  329.         ix = ix -> next;
  330.     }
  331.     if (force == TRUE) {
  332.         args[i] = NULLCP;
  333.         args[2] = rcmd_srch((int) msgstart, msgtbl_commands);
  334.         my_invoke(msgstart, args);
  335.     }
  336.     for (j = 3; j < i; j++)
  337.         if (args[j] != NULLCP) {
  338.             free(args[j]);
  339.             args[j] = NULLCP;
  340.         }
  341.     i = 3;
  342.     ix = msg -> reciplist;
  343.     force = FALSE;
  344.     while (ix != NULL) {
  345.         if (ix -> status
  346.             && ix -> status -> cachedUntil != 0) {
  347.             args[i++] = itoa(ix->id);
  348.  
  349.             force = TRUE;
  350.         }
  351.         ix = ix -> next;
  352.     }
  353.     if (force == TRUE) {
  354.         args[i] = NULLCP;
  355.         args[2] = rcmd_srch((int) msgclear, msgtbl_commands);
  356.         my_invoke(msgstart, args);
  357.     }
  358.     for (j = 3; j < i; j++)
  359.         if (args[j] != NULLCP) {
  360.             free(args[j]);
  361.             args[j] = NULLCP;
  362.         }
  363.     free ((char *) args);
  364. }
  365.  
  366. MsgControl(op, msg, usrs, time)
  367. Operations    op;
  368. char        *msg;
  369. char        *usrs;
  370. char        *time;
  371. {
  372.     char    *str0,
  373.         *str1,
  374.         *qid,
  375.         *usrlist[20],
  376.         **args;
  377.     int    numberUsrs,
  378.         i = 0,
  379.         ix;
  380.  
  381.     /* arg1 = QID arg2 = time arg3 = control arg4.. = userlist */
  382.     
  383.     /* get selection and all that */
  384.     str0 = strdup(msg);
  385.     qid = stripstr(str0);
  386.  
  387.     str1 = strdup(usrs);
  388.     numberUsrs = sstr2arg(str1, 20, usrlist, ",");
  389.     
  390.     args = (char **) calloc((unsigned)(4+numberUsrs), sizeof(char *));
  391.     args[0] = qid;
  392.     args[1] = time;
  393.     args[2] = rcmd_srch((int) op, msgtbl_commands);
  394.     ix = 3;
  395.     while(i < numberUsrs && ix < (3+numberUsrs)) 
  396.         args[ix++] = usrlist[i++];
  397.     my_invoke(op, args);
  398.     free((char *) args);
  399.     free(str0);
  400.     free(str1);
  401. }
  402.  
  403. /*   */
  404.  
  405. extern struct chan_struct    *find_channel();
  406.  
  407. /* ARGSUSED */
  408. ChanInfo(channel)
  409. char    *channel;
  410. {
  411.     struct chan_struct    *chan;
  412.     char    *channame,
  413.         *str;
  414.  
  415.     str = strdup(channel);
  416.     channame = stripstr(str);
  417.  
  418.     if ((chan = find_channel(channame)) != NULL) {
  419.         chan_display_info(chan);
  420.     } else {
  421.         /* put out error message */
  422.         PP_LOG(LLOG_EXCEPTIONS,
  423.                ("MTAcosnole confused: Unable to find '%s'",
  424.             channame));
  425.     }
  426.     free(str);
  427. }
  428.  
  429. extern struct mta_struct    *find_mta();
  430.  
  431. /* ARGSUSED */
  432. MtaInfo(mtain, channel)
  433. char    *mtain,
  434.     *channel;
  435. {
  436.     struct chan_struct    *chan;
  437.     struct mta_struct    *mta;
  438.     char    *mtaname,
  439.         *channame,
  440.         *str1,
  441.         *str2;
  442.  
  443.     str1 = strdup(channel);
  444.     channame = stripstr(str1);
  445.     str2 = strdup(mtain);
  446.     mtaname = stripstr(str2);
  447.  
  448.     if (((chan = find_channel(channame)) != NULL)
  449.         && ((mta = find_mta(chan, mtaname)) != NULL)) {
  450.         mta_display_info(chan, mta);
  451.     } else {
  452.         /* put out error message */
  453.         PP_LOG(LLOG_EXCEPTIONS,
  454.                ("MTAconsole confused: unable to find channel/mta pair '%s/%s'",
  455.             channame, mtaname));
  456.     }
  457.     free(str1);
  458.     free(str2);
  459.  
  460. }
  461.  
  462. extern struct msg_struct    *find_msg();
  463. /* ARGSUSED */
  464. MsgInfo(msgin)
  465. char    *msgin;
  466. {
  467.     struct msg_struct    *msg;
  468.     char    *qid,
  469.         *str;
  470.     str = strdup(msgin);
  471.     qid = stripstr(str);
  472.  
  473.     if ((msg = find_msg(qid)) != NULL)
  474.         msg_display_info(msg);
  475.     free(str);
  476.  
  477. }
  478.  
  479. /*   */
  480. extern State    connectState;
  481. extern int    userConnected,
  482.         autoReconnect;
  483. extern Widget    header, error;
  484. extern char    *hostname;
  485.  
  486. /* ARGSUSED */
  487. Disconnect()
  488. {
  489.     /* put out required message */
  490.     XtVaSetValues(header,
  491.           XtNlabel, NO_CONNECTION,
  492.           NULL);
  493.     XtSetMappedWhenManaged(error, False);
  494.     userConnected = FALSE;
  495.     TermRefreshTimeOut();
  496.     TermConnectRetry();
  497.     TermConnectTimeOut();
  498.     ResetForDisconnect();
  499.     my_invoke(disconnect, &hostname);
  500.     SensitizeButtons(False);
  501. }
  502.  
  503. /* ARGSUSED */
  504. Connect(host)
  505. char    *host;
  506. {
  507.     char    *str,
  508.         *convertedstr;
  509.  
  510.     str = strdup(host);
  511.  
  512.     convertedstr = stripstr(host);
  513.  
  514.     if (strcmp(hostname, convertedstr) != 0) {
  515.         free(hostname);
  516.         hostname = strdup(convertedstr);
  517.     }
  518.     free(str);
  519.  
  520.     if (autoReconnect == TRUE) userConnected = TRUE;
  521.  
  522.     my_invoke(connect, &hostname);
  523. }
  524.         
  525. /* ARGSUSED */
  526. Quit()
  527. {
  528.     my_invoke(quit,(char **) NULL);
  529. }
  530.  
  531. /*   */
  532.  
  533. extern struct chan_struct    *currentchan,
  534.                 **globallist;
  535. extern struct mta_struct    *currentmta;
  536. extern struct monitor_item    **display_list;
  537. extern int            read_currentchan;
  538. extern int            read_currentmta;
  539. extern Widget            *channel_array;
  540. extern int            num_channels;
  541. extern Widget            channel_label;
  542. extern Widget            mta_label;
  543. extern Mode            mode;
  544. extern struct msg_struct    *currentmsg;
  545. extern Widget            msg_label;
  546.  
  547. /* ARGSUSED */
  548. void curChan (w, event, params, num_params)
  549. Widget    w;
  550. XEvent    *event;
  551. char    **params;
  552. int    num_params;
  553. {
  554.     int    i = 0;
  555.     ResetInactiveTimeout();
  556.     while (i < num_channels
  557.            && channel_array[i] != w) i++;
  558.  
  559.     if (i < num_channels) {
  560.         if (mode == monitor)
  561.             ChangeMode((Widget)NULL, (caddr_t) NULL, 
  562.                    (caddr_t) NULL);
  563.  
  564.         if (currentchan != globallist[i]) {
  565.             read_currentmta = 0;
  566.             currentmta = NULL;
  567.             currentmsg = NULL;
  568.             currentchan = globallist[i];
  569.         }
  570.     }
  571.     reset_label(channel_label);
  572.     reset_label(mta_label);
  573.     reset_label(msg_label);
  574. }
  575.  
  576. /* ARGSUSED */
  577. void excl_curChan (w, event, params, num_params)
  578. Widget    w;
  579. XEvent    *event;
  580. char    **params;
  581. int    num_params;
  582. {
  583.     int    i = 0;
  584.     ResetInactiveTimeout();
  585.     while (i < num_channels
  586.            && channel_array[i] != w) i++;
  587.  
  588.     read_currentchan = 0;
  589.     if (i < num_channels) {
  590.         if (mode == monitor)
  591.             ChangeMode((Widget)NULL, 
  592.                    (caddr_t) NULL, (caddr_t) NULL);
  593.  
  594.         if (currentchan != NULL) 
  595.             display_empty_mta_list(currentchan);
  596.         display_empty_msg_list();
  597.  
  598.         if (currentchan == globallist[i]) 
  599.             /* deselect it */
  600.             currentchan = NULL;
  601.         else 
  602.             currentchan = globallist[i];
  603.  
  604.         currentmta = NULL;
  605.         currentmsg = NULL;
  606.         read_currentmta = 0;
  607.         MtaToggle();
  608.         MsgToggle();
  609.     }
  610.     reset_label(channel_label);
  611.     reset_label(mta_label);
  612.     reset_label(msg_label);
  613. }
  614.  
  615. /* ARGSUSED */
  616. void chanRefresh (w, event, params, num_params)
  617. Widget    w;
  618. XEvent    *event;
  619. char    **params;
  620. int    num_params;
  621. {
  622.     int    i = 0;
  623.     struct chan_struct    *chan;
  624.  
  625.     while (i < num_channels && display_list[i]->chan != w)
  626.         i++;
  627.     
  628.     if (i < num_channels) {
  629.         chan = *(display_list[i]->channel);
  630.         add_mta_refresh_list (chan->channelname);
  631.         construct_event(mtaread);
  632.     }
  633. }
  634.         
  635. /* ARGSUSED */
  636. void chanModeRead (w, event, params, num_params)
  637. Widget    w;
  638. XEvent    *event;
  639. char    **params;
  640. int    num_params;
  641. {
  642.     int    i = 0;
  643.  
  644.     while (i < num_channels && display_list[i]->chan != w)
  645.         i++;
  646.     
  647.     if (i < num_channels) {
  648.         read_currentchan = 1;
  649.         currentchan = *(display_list[i]->channel);
  650.         reset_label(channel_label);
  651.         ChangeMode(w, (caddr_t) NULL, (caddr_t) NULL);
  652.     }
  653. }
  654.  
  655. /* ARGSUSED */
  656. void chanMode (w, event, params, num_params)
  657. Widget    w;
  658. XEvent    *event;
  659. char    **params;
  660. int    num_params;
  661. {
  662.     int    i = 0;
  663.  
  664.     while (i < num_channels && display_list[i]->chan != w)
  665.         i++;
  666.     
  667.     if (i < num_channels) {
  668.         read_currentchan = 0;
  669.         currentchan = *(display_list[i]->channel);
  670.         reset_label(channel_label);
  671.         ChangeMode(w, (caddr_t) NULL, (caddr_t) NULL);
  672.     }
  673. }
  674.  
  675. /* ARGSUSED */
  676. void readChan (w, event, params, num_params)
  677. Widget    w;
  678. XEvent    *event;
  679. char    **params;
  680. int    num_params;
  681. {
  682.     ResetInactiveTimeout();
  683.     if (currentchan != NULL) {
  684.         ChanToggle();
  685.         MtaToggle();
  686.         MsgToggle();
  687.         read_currentchan = 1;
  688.         if (mode == control) {
  689.             clear_mta_refresh_list();
  690.             add_mta_refresh_list(currentchan->channelname);
  691.             construct_event(mtaread);
  692.         }
  693.     }
  694. }
  695.         
  696. char                *msginfo_args[3];
  697. extern struct mta_disp_struct    *mta_array;
  698. int                actual_nmtas_present;
  699.  
  700. MtaNext()
  701. {
  702.     if (currentchan == NULL || 
  703.         actual_nmtas_present == 0)
  704.         return;
  705.     if (currentmta == NULL)
  706.         currentmta = mta_array[0].mta;
  707.     else {
  708.         int i = 0;
  709.         while (i < actual_nmtas_present
  710.                && currentmta != mta_array[i].mta) i++;
  711.         if (i >= actual_nmtas_present-1)
  712.             currentmta = mta_array[0].mta;
  713.         else
  714.             currentmta = mta_array[i+1].mta;
  715.     }
  716.     currentmsg = NULL;
  717.     refresh_mta_control();
  718. }
  719.  
  720. MtaPrev()
  721. {
  722.     if (currentchan == NULL || 
  723.         actual_nmtas_present == 0)
  724.         return;
  725.     if (currentmta == NULL)
  726.         currentmta = mta_array[actual_nmtas_present-1].mta;
  727.     else {
  728.         int i = 0;
  729.         while (i < actual_nmtas_present
  730.                && currentmta != mta_array[i].mta) i++;
  731.         if (i == 0)
  732.             currentmta = mta_array[actual_nmtas_present-1].mta;
  733.         else
  734.             currentmta = mta_array[i-1].mta;
  735.     }
  736.     currentmsg = NULL;
  737.     refresh_mta_control();
  738. }
  739.  
  740. refresh_mta_control()
  741. {
  742.     reset_label(mta_label);
  743.     reset_label(msg_label);
  744.     if (currentchan != NULL
  745.         && currentmta != NULL) {
  746.         if (read_currentmta) {
  747.             msginfo_args[0] = currentchan->channelname;
  748.             msginfo_args[1] = currentmta->mta;
  749.             if (currentchan->chantype == int_Qmgr_chantype_mts
  750.                 && currentchan->outbound > 0)
  751.                 msginfo_args[2] = (char *) 1;
  752.             else
  753.                 msginfo_args[2] = (char *) 0;
  754.             my_invoke(readchannelmtamessage, msginfo_args);
  755.         }
  756.  
  757.         if (mta_info_shown == TRUE)
  758.             mta_display_info(currentchan, currentmta);
  759.     }
  760. }
  761.  
  762. /* ARGSUSED */
  763. void curMta (w, event, params, num_params)
  764. Widget    w;
  765. XEvent    *event;
  766. char    **params;
  767. int    num_params;
  768. {
  769.     int    i = 0;
  770.     ResetInactiveTimeout();
  771.     while (i < actual_nmtas_present
  772.            && mta_array[i].widget != w) i++;
  773.  
  774.     if (i < actual_nmtas_present && currentmta != mta_array[i].mta) {
  775.         currentmta = mta_array[i].mta;
  776.         currentmsg = NULL;
  777.     }
  778.     reset_label(mta_label);
  779.     reset_label(msg_label);
  780. }
  781.  
  782. /* ARGSUSED */
  783. void excl_curMta (w, event, params, num_params)
  784. Widget    w;
  785. XEvent    *event;
  786. char    **params;
  787. int    num_params;
  788. {
  789.     int    i = 0;
  790.     ResetInactiveTimeout();
  791.     while (i < actual_nmtas_present
  792.            && mta_array[i].widget != w) i++;
  793.     read_currentmta = 0;
  794.     
  795.     if (i < actual_nmtas_present) {
  796.  
  797.         display_empty_msg_list();
  798.  
  799.         if (currentmta == mta_array[i].mta)   
  800.             /* deselect it */
  801.             currentmta = NULL;
  802.         else
  803.             currentmta = mta_array[i].mta;
  804.  
  805.         currentmsg = NULL;
  806.         MsgToggle();
  807.     }
  808.     reset_label(mta_label);
  809.     reset_label(msg_label);
  810. }
  811.  
  812. /* ARGSUSED */
  813. void mtaRefresh (w, event, params, num_params)
  814. Widget    w;
  815. XEvent    *event;
  816. char    **params;
  817. int    num_params;
  818. {
  819.     int    i = 0,j = 0, found = 0;
  820.     struct chan_struct    *chan;
  821.  
  822.     while (i < num_channels 
  823.            && found == 0) {
  824.         j = 0;
  825.         while (j < display_list[i]->num_mtas
  826.                && found == 0) {
  827.             if (display_list[i]->mtas[j]->widget == w)
  828.                 found = 1;
  829.             else
  830.                 j++;
  831.         }
  832.         if (found == 0) 
  833.             i++;
  834.     }
  835.     if (found == 1) {
  836.         chan = *(display_list[i]->channel);
  837.         add_mta_refresh_list (chan->channelname);
  838.         construct_event(mtaread);
  839.     }
  840. }
  841.  
  842. /* ARGSUSED */
  843. void mtaModeRead (w, event, params, num_params)
  844. Widget    w;
  845. XEvent    *event;
  846. char    **params;
  847. int    num_params;
  848. {
  849.     int    i = 0,j = 0, found = 0;
  850.  
  851.     while (i < num_channels 
  852.            && found == 0) {
  853.         j = 0;
  854.         while (j < display_list[i]->num_mtas
  855.                && found == 0) {
  856.             if (display_list[i]->mtas[j]->widget == w)
  857.                 found = 1;
  858.             else
  859.                 j++;
  860.         }
  861.         if (found == 0) 
  862.             i++;
  863.     }
  864.     if (found == 1) {
  865.         read_currentchan = 1;
  866.         currentchan = *(display_list[i]->channel);
  867.         read_currentmta = 1;
  868.         currentmta = display_list[i]->mtas[j]->mta;
  869.         ChangeMode(w, (caddr_t) NULL, (caddr_t) NULL);
  870.     }
  871. }
  872.  
  873. /* ARGSUSED */
  874. void mtaMode (w, event, params, num_params)
  875. Widget    w;
  876. XEvent    *event;
  877. char    **params;
  878. int    num_params;
  879. {
  880.     int    i = 0,j = 0, found = 0;
  881.  
  882.     while (i < num_channels 
  883.            && found == 0) {
  884.         j = 0;
  885.         while (j < display_list[i]->num_mtas
  886.                && found == 0) {
  887.             if (display_list[i]->mtas[j]->widget == w)
  888.                 found = 1;
  889.             else
  890.                 j++;
  891.         }
  892.         if (found == 0) 
  893.             i++;
  894.     }
  895.     if (found == 1) {
  896.         read_currentchan = 1;
  897.         currentchan = *(display_list[i]->channel);
  898.         read_currentmta = 0;
  899.         currentmta = display_list[i]->mtas[j]->mta;
  900.         ChangeMode(w, (caddr_t) NULL, (caddr_t) NULL);
  901.     }
  902. }
  903.  
  904. /* ARGSUSED */
  905. void readMta (w, event, params, num_params)
  906. Widget    w;
  907. XEvent    *event;
  908. char    **params;
  909. int    num_params;
  910. {
  911.     ResetInactiveTimeout();
  912.     MtaToggle();
  913.     MsgToggle();
  914.     if (currentchan != NULL && currentmta != NULL) {
  915.         msginfo_args[0] = currentchan->channelname;
  916.         read_currentmta = 1;
  917.         msginfo_args[1] = currentmta->mta;
  918.         if (currentchan->chantype == int_Qmgr_chantype_mts
  919.             && currentchan->outbound > 0)
  920.             msginfo_args[2] = (char *) 1;
  921.         else
  922.             msginfo_args[2] = (char *) 0;
  923.         my_invoke(readchannelmtamessage, msginfo_args);
  924.     }
  925. }
  926.  
  927. extern struct msg_disp_struct    *msg_array;
  928. extern int            actual_nmsgs_present;
  929.  
  930.  
  931. MsgNext()
  932. {
  933.     if (actual_nmsgs_present == 0)
  934.         return;
  935.     if (currentmsg == NULL)
  936.         currentmsg = msg_array[0].msg;
  937.     else {
  938.         int i = 0;
  939.         while (i < actual_nmsgs_present
  940.                && msg_array[i].msg != currentmsg) i++;
  941.         
  942.         if (i >= actual_nmsgs_present-1)
  943.             currentmsg = msg_array[0].msg;
  944.         else
  945.             currentmsg = msg_array[i+1].msg;
  946.     }
  947.     refresh_msg_control();
  948. }
  949.                    
  950. MsgPrev()
  951. {
  952.     if (actual_nmsgs_present == 0)
  953.         return;
  954.     if (currentmsg == NULL)
  955.         currentmsg = msg_array[actual_nmsgs_present-1].msg;
  956.     else {
  957.         int i = 0;
  958.         while (i < actual_nmsgs_present
  959.                && msg_array[i].msg != currentmsg) i++;
  960.         
  961.         if (i == 0)
  962.             currentmsg = msg_array[actual_nmsgs_present-1].msg;
  963.         else
  964.             currentmsg = msg_array[i-1].msg;
  965.     }
  966.     refresh_msg_control();
  967. }
  968.                    
  969. refresh_msg_control()
  970. {
  971.     reset_label(msg_label);
  972.     if (currentmsg && msg_info_shown)
  973.         msg_display_info(currentmsg);
  974. }
  975.  
  976. /* ARGSUSED */
  977. void curMsg (w, event, params, num_params)
  978. Widget    w;
  979. XEvent    *event;
  980. char    **params;
  981. int    num_params;
  982. {
  983.     int    i = 0;
  984.     ResetInactiveTimeout();
  985.     while (i < actual_nmsgs_present
  986.            && msg_array[i].widget != w) i++;
  987.  
  988.     if (i < actual_nmsgs_present) {
  989.         currentmsg = msg_array[i].msg;
  990.     }
  991.     reset_label(msg_label);
  992. }
  993.  
  994. /* ARGSUSED */
  995. void excl_curMsg (w, event, params, num_params)
  996. Widget    w;
  997. XEvent    *event;
  998. char    **params;
  999. int    num_params;
  1000. {
  1001.     int    i = 0;
  1002.     ResetInactiveTimeout();
  1003.     while (i < actual_nmsgs_present
  1004.            && msg_array[i].widget != w) i++;
  1005.  
  1006.     if (i < actual_nmsgs_present) {
  1007.         if (currentmsg == msg_array[i].msg) {   
  1008.             /* deselect it */
  1009.             MsgToggle();
  1010.             currentmsg = NULL;
  1011.         } else 
  1012.             currentmsg = msg_array[i].msg;
  1013.     }
  1014.     reset_label(msg_label);
  1015. }
  1016.  
  1017. /* ARGSUSED */
  1018. void readMsg (w, event, params, num_params)
  1019. Widget    w;
  1020. XEvent    *event;
  1021. char    **params;
  1022. int    num_params;
  1023. {
  1024.     if (currentmsg != NULL)
  1025.         msg_display_info(currentmsg);
  1026. }
  1027.